<template>
  <base-container>
    <el-radio-group v-model="radioValue" size="large" @change="handleRadio">
      <el-radio-button v-for="item in radioOptions" :key="item.value" v-bind="item" />
    </el-radio-group>
    <section v-if="radioValue === '1'" class="py-20px">
      <avue-table-search
        v-model="searchParams"
        :option="serviceConsumerSearchOption"
        @search-change="loadTableSearch"
        @search-reset="loadTableSearchReset"
      />
      <!-- 卡片容器 -->
      <base-table-card>
        <avue-crud
          v-model="formData"
          :data="tableData"
          :option="serviceConsumerTableOption"
          :page="page"
          :table-loading="tableLoading"
          @refresh-change="loadGetTableData"
          @current-change="loadTablePageChange"
          @size-change="loadTablePageSizeChange"
          @row-save="loadAdd"
          @row-update="loadEdit"
        >
          <template #changeAmountStr="{ row }">
            <el-text :type="row.changeAmountStr * 1 < 0 ? 'danger' : ''">{{ row.changeAmountStr }}</el-text>
          </template>
        </avue-crud>
      </base-table-card>
    </section>
    <section v-if="radioValue === '2'" class="py-20px">
      <avue-table-search
        v-model="searchParams"
        :option="rechargeRecordSearchOption"
        @search-change="loadTableSearch"
        @search-reset="loadTableSearchReset"
      />
      <!-- 卡片容器 -->
      <base-table-card>
        <avue-crud
          v-model="formData"
          :data="tableData"
          :option="rechargeRecordTableOption"
          :page="page"
          :table-loading="tableLoading"
          @refresh-change="loadGetTableData"
          @current-change="loadTablePageChange"
          @size-change="loadTablePageSizeChange"
          @row-save="loadAdd"
          @row-update="loadEdit"
        >
          <template #changeAmountStr="{ row }">
            <el-text :type="row.changeAmountStr * 1 < 0 ? 'danger' : ''">{{ row.changeAmountStr }}</el-text>
          </template>
        </avue-crud>
      </base-table-card>
    </section>
    <section v-if="radioValue === '3'" class="py-20px">
      <avue-table-search
        v-model="searchParams"
        :option="enterpriseLeaseSearchOption"
        @search-change="loadTableSearch"
        @search-reset="loadTableSearchReset"
      />
      <!-- 卡片容器 -->
      <base-table-card>
        <avue-crud
          v-model="formData"
          :data="tableData"
          :option="enterpriseLeaseTableOption"
          :page="page"
          :table-loading="tableLoading"
          @refresh-change="loadGetTableData"
          @current-change="loadTablePageChange"
          @size-change="loadTablePageSizeChange"
          @row-save="loadAdd"
          @row-update="loadEdit"
        >
          <template #changeAmountStr="{ row }">
            <el-text :type="row.changeAmountStr * 1 < 0 ? 'danger' : ''">{{ row.changeAmountStr }}</el-text>
          </template>
        </avue-crud>
      </base-table-card>
    </section>
  </base-container>
</template>

<script setup>
  import {
    serviceConsumerSearchOption,
    serviceConsumerTableOption,
    rechargeRecordSearchOption,
    rechargeRecordTableOption,
    enterpriseLeaseSearchOption,
    enterpriseLeaseTableOption,
  } from "@/crudOption/finance/business/CapitalAccountDetail.js";
  import useCrudHook from "avue-table/useCrudHook";
  // 增删改查 hook
  let {
    data: tableData,
    loading: tableLoading,
    page: page,
    search: searchParams,
    form: formData,
    get: loadGetTableData,
    add: loadAdd,
    edit: loadEdit,
    pageNumChange: loadTablePageChange,
    pageSizeChange: loadTablePageSizeChange,
    searchReset: loadTableSearchReset,
    searchChange: loadTableSearch,
  } = useCrudHook({
    get: Api.product.getAddressList,
    search: { status: "01" },
    getParamsFormat: params => {
      // // 开通时间
      // if (params.createTime && params.createTime.length === 2) {
      //   params.createTimeStart = params.createTime[0];
      //   params.createTimeEnd = params.createTime[1];
      //   delete params.createTime;
      // }
      // // 到期时间
      // if (params.expiredTime && params.expiredTime.length === 2) {
      //   params.expiredTimeStart = params.expiredTime[0];
      //   params.expiredTimeEnd = params.expiredTime[1];
      //   delete params.expiredTime;
      // }
      // // console.log(params, "params");
      // // 返回查询参数
      return params;
    },
    // add: Api.customer.AddCustomer,
    // edit: Api.customer.UpdateCustomer,
  });

  //单选按钮切换值
  const radioValue = ref("1");
  // 点击切换
  const handleRadio = value => {
    console.log(value);
  };
  //单选按钮选项
  const radioOptions = ref([
    { label: "服务消费列表", value: "1" },
    { label: "充值记录", value: "2" },
    { label: "企业租赁", value: "3" },
  ]);

  onMounted(() => {
    tableData.value = [
      {
        id: 58418631,
        shopId: "624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        operate: "CONTRACT",
        operator: "15012885951",
        changeAmount: 2,
        beforeAmount: 3181.29,
        afterAmount: 3179.29,
        flowNo: "CONTRACT1760345817522624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        remark: "{\"otherInfo\":\"合同查询\",\"CONTRACT\":\"OI1977659761671405568\"}",
        createTime: "2025-10-13 16:56:58",
        changeAmountStr: "2.00",
      },
      {
        id: 58418630,
        shopId: "624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        operate: "SMS",
        operator: "系统平台",
        changeAmount: 0.05,
        beforeAmount: 3181.34,
        afterAmount: 3181.29,
        flowNo: "SMS1760345809230624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        remark: "{\"otherInfo\":\"TO_SHOP_NOW批次号17603458090879559\",\"SMS\":\"OI1977659761671405568\"}",
        createTime: "2025-10-13 16:56:49",
        changeAmountStr: "-0.05",
      },
      {
        id: 58418629,
        shopId: "624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        operate: "CREDIT_REPORT",
        operator: "系统平台",
        changeAmount: 0,
        beforeAmount: 3181.34,
        afterAmount: 3181.34,
        flowNo: "credit_report1760344674732624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        remark: "{\"creditReport\":1760344674732}",
        createTime: "2025-10-13 16:37:55",
        changeAmountStr: "0.00",
      },
      {
        id: 58418628,
        shopId: "624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        operate: "SMS",
        operator: "系统平台",
        changeAmount: 0.05,
        beforeAmount: 3181.39,
        afterAmount: 3181.34,
        flowNo: "SMS1760344667378624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        remark: "{\"otherInfo\":\"商家发货短信\",\"SMS\":\"OI1977654240658718720\"}",
        createTime: "2025-10-13 16:37:47",
        changeAmountStr: "-0.05",
      },
      {
        id: 58418627,
        shopId: "624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        operate: "CONTRACT",
        operator: "19999999999",
        changeAmount: 2,
        beforeAmount: 3183.39,
        afterAmount: 3181.39,
        flowNo: "CONTRACT1760344648503624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        remark: "{\"otherInfo\":\"合同查询\",\"CONTRACT\":\"OI1977654240658718720\"}",
        createTime: "2025-10-13 16:37:29",
        changeAmountStr: "-2.00",
      },
      {
        id: 58418626,
        shopId: "624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        operate: "SMS",
        operator: "系统平台",
        changeAmount: 0.05,
        beforeAmount: 3183.44,
        afterAmount: 3183.39,
        flowNo: "SMS1760344634451624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        remark: "{\"otherInfo\":\"TO_SHOP_NOW批次号17603446343886774\",\"SMS\":\"OI1977654240658718720\"}",
        createTime: "2025-10-13 16:37:14",
        changeAmountStr: "-0.05",
      },
      {
        id: 58418625,
        shopId: "624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        operate: "CREDIT_REPORT",
        operator: "系统平台",
        changeAmount: 0,
        beforeAmount: 3183.44,
        afterAmount: 3183.44,
        flowNo: "credit_report1760342929833624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        remark: "{\"creditReport\":1760342929833}",
        createTime: "2025-10-13 16:08:50",
        changeAmountStr: "0.00",
      },
      {
        id: 58418624,
        shopId: "624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        operate: "SMS",
        operator: "系统平台",
        changeAmount: 0.05,
        beforeAmount: 3183.49,
        afterAmount: 3183.44,
        flowNo: "SMS1760342925113624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        remark: "{\"otherInfo\":\"商家发货短信\",\"SMS\":\"OI1977647070097571840\"}",
        createTime: "2025-10-13 16:08:45",
        changeAmountStr: "-0.05",
      },
      {
        id: 58418623,
        shopId: "624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        operate: "CONTRACT",
        operator: "19999999999",
        changeAmount: 2,
        beforeAmount: 3185.49,
        afterAmount: 3183.49,
        flowNo: "CONTRACT1760342823092624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        remark: "{\"otherInfo\":\"合同查询\",\"CONTRACT\":\"OI1977647070097571840\"}",
        createTime: "2025-10-13 16:07:03",
        changeAmountStr: "-2.00",
      },
      {
        id: 58418622,
        shopId: "624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        operate: "SMS",
        operator: "系统平台",
        changeAmount: 0.05,
        beforeAmount: 3185.54,
        afterAmount: 3185.49,
        flowNo: "SMS1760342809173624d20efd7b0a139281136e9bcfc7c3271e7d9e5",
        remark: "{\"otherInfo\":\"TO_SHOP_NOW批次号17603428091136217\",\"SMS\":\"OI1977647070097571840\"}",
        createTime: "2025-10-13 16:06:49",
        changeAmountStr: "-0.05",
      },
    ];
  });

  //platformAccount
</script>

<style scoped></style>
